package com.rssreader.client.mvc.controllers;

import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.rssreader.client.mvc.events.AppEvents;
import com.rssreader.client.mvc.views.AppView;

public class AppController extends Controller {
    public AppController() {
	registerEventTypes(AppEvents.Init);
	registerEventTypes(AppEvents.Error);
	registerEventTypes(AppEvents.UIReady);
	registerEventTypes(AppEvents.NavPanelReady);
	registerEventTypes(AppEvents.FeedPanelReady);
	registerEventTypes(AppEvents.ItemPanelReady);

	registerEventTypes(AppEvents.StatusToolbarReady);
    }

    private View appView;

    // 可透過canHandle()定義controller是否可以處理特定的AppEvent
    @Override
    public void handleEvent(AppEvent event) {
	// forward all the events to the associated view
	forwardToView(appView, event);
    }

    // 透過initialize去關聯controller和view
    @Override
    protected void initialize() {
	super.initialize();
	appView = new AppView(this);
    }

}
